package com.test;

import java.util.concurrent.atomic.AtomicMarkableReference;

public class TAtomicMarkableReference {
    public static void main(String[] args) {
        AtomicMarkableReference<String> t = new AtomicMarkableReference<String>("a",false);

        System.out.println(" @ "+t.getReference()+" "+t.isMarked());

        boolean mark = t.isMarked();

        boolean s1 = t.compareAndSet("a","b",false,true);
        System.out.println(s1+" @ "+t.getReference()+" "+t.isMarked());

        boolean s2 = t.compareAndSet("b","a",true,false);
        System.out.println(s2+" @ "+t.getReference()+" "+t.isMarked());

        boolean s3 = t.compareAndSet("a","c",mark,!mark);
        System.out.println(s3+" @ "+t.getReference()+" "+t.isMarked());
    }
}
